import { Repository } from "typeorm";
import { UserEntity } from "../entity/user.entity";
import { InjectRepository } from "@nestjs/typeorm";
import { HttpException } from "@nestjs/common";

export class UserService {
  constructor(
    @InjectRepository(UserEntity)
    private readonly userRepository: Repository<UserEntity>
  ) {
  }

  async getProfile(userId: number) {
    const user = await this.userRepository.findOne({
      where: {
        id: userId
      }
    });
    if (!user) {
      throw new HttpException("用户不存在", 400);
    }
    return user
  }
}
